package top.canyue.word_range_service.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.canyue.word_range.pojo.dto.ConditionDto;
import top.canyue.word_range.pojo.po.Condition;
import top.canyue.word_range.pojo.vo.ConditionVo;
import top.canyue.word_range.result.Result;
import top.canyue.word_range_service.service.ConditionService;

import java.util.List;

/**
 * 活动达成条件相关接口
 * TODO: 条件后续再实现
 * @author canyue
 */

@RestController
@RequestMapping("/apiV1/condition")
@RequiredArgsConstructor
public class ConditionController {
    final ConditionService conditionService;

    /// 添加达成条件
    @PostMapping("/")
    public Result<Condition> addCondition(@RequestHeader String JWT, @RequestBody ConditionDto conditionDto) {
        return conditionService.addCondition(conditionDto);
    }

    /// 更新达成条件
    @PutMapping("/")
    public Result<Condition> updateCondition(@RequestHeader String JWT, @RequestBody ConditionDto conditionDto){
        return conditionService.updateCondition(conditionDto);
    }

    /// 删除达成条件
    @DeleteMapping("/{conditionId}")
    public Result<Condition> deleteCondition(@RequestHeader String JWT, @PathVariable String conditionId){
        return conditionService.deleteCondition(conditionId);
    }

    /// 为活动添加达成条件
    @PostMapping("/associatedCondition")
    public Result<Condition> associatedCondition(@RequestHeader String JWT, String conditionId, String EventId){
        return conditionService.associatedCondition(conditionId, EventId);
    }

    /// 获取某一活动下条件列表
    @GetMapping("/getConditionListByEvent/{eventId}")
    public Result<List<ConditionVo>> getConditionListByEvent(@RequestHeader String JWT, @PathVariable String eventId){
        return conditionService.getConditionListByEvent(eventId);
    }


}
